package com.hontech.pastacooking.model

import com.hontech.pastacooking.ext.isSetBit
import com.hontech.pastacooking.serial.UInt16

class FridgeStatus {

    val sw = UInt16()
    val temp = UInt16()

    fun tempValue(): Int {
        val value = temp.value
        if (value.isSetBit(15)) {
            return -(0x10000 - value)
        }
        return value
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as FridgeStatus

        if (sw != other.sw) return false
        if (temp != other.temp) return false

        return true
    }

    override fun hashCode(): Int {
        var result = sw.hashCode()
        result = 31 * result + temp.hashCode()
        return result
    }


}